﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Models;

public partial class Admin_User_Order_dtails : System.Web.UI.Page
{
    public int _Id = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.CacheControl = "no-cache";
        if (!string.IsNullOrEmpty(Request.Params["ID"]))
        {
            _Id = int.Parse(HttpContext.Current.Request.QueryString["ID"]);
        }
        grbind();
    }

    //显示
    public void grbind()
    {
        Entities db = new Entities();
        var info = db.S_Order.SingleOrDefault(p => p.OrderID == _Id);
        if (info != null)
        {
          
                id.Text = info.OrderID.ToString();
                GoodName.Text = getallgname(_Id);
                OCount.Text = getallOnumber(_Id);
                OPeople.Text = info.OPeople.ToString();
                OTel.Text = info.OTel.ToString();
                  
            
              
        }
    }



    protected string getallgname(int order_id)
    {
        string xxx = "";
        if (order_id != 0)
        {
            using (Entities MyDB = new Entities())
            {
                var mnews = MyDB.S_Order.Where(x => x.OParentId == order_id || x.OrderID == order_id);//全部
                foreach (var myorder in mnews)
                    xxx += myorder.SPName + "x(" + myorder.ONumber + ")" + "<br style='mso-data-placement:same-cell;'/>";
            }
        }
        return xxx;
    }
    protected string getallOnumber(int order_id)
    {
        string xxx = "";
        if (order_id != 0)
        {
            using (Entities MyDB = new Entities())
            {
                xxx = MyDB.S_Order.Where(x => x.OParentId == order_id || x.OrderID == order_id).Sum(x => x.ONumber).ToString();//全部

            }
        }
        return xxx;
    }


    public string getexcelPayState(int state)
    {
        string Result;
        if (state == 1)
        {
            Result = "邮费已支付";
        }
        else
        {
            Result = "邮费未支付";
        }
        return Result;
    }


}
